{extend name="base" /}
{block name="content"}
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>商城</span>
            <span class="icon-angle-right"></span>
            <span>积分订单管理</span>
            <span class="icon-angle-right"></span>
            <span>积分订单详情</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <thead>
                            <tr>
                                <th colspan="4">查看积分订单详情</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td width="15%"><label>订单 ID</label></td>
                                <td width="35%">{$info.id}</td>
                                <td width="15%"><label>订单编号</label></td>
                                <td width="35%">{$info.order_no}</td>
                            </tr>
                            <tr>
                                <td width="15%"><label>下单会员</label></td>
                                <td width="35%">{$info.username}</td>
                                <td width="15%"><label>收货人</label></td>
                                <td width="35%">{$info.receiver_name}</td>
                            </tr>
                            <tr>
                                <td width="15%"><label>收货人联系方式</label></td>
                                <td width="35%">{$info.receiver_mobile}</td>
                                <td width="15%"><label>收货人地址</label></td>
                                <td width="35%">{$info.receiver_province}{$info.receiver_city}{$info.receiver_district}{$info.receiver_address}</td>
                            </tr>
                            <tr>
                            	<td width="15%"><label>订单所需我只要</label></td>
                                <td width="35%">{$info.points}</td>
                                <td width="15%"><label>实付积分</label></td>
                                <td width="35%">{$info.pay_amount}</td>
                            </tr>
                            <tr>
                            	<td width="15%"><label>快递单号</label></td>
                                <td width="35%">{$info.courier}</td>
                                <td width="15%"><label>订单状态</label></td>
                                <td width="35%" data-id="{$info.id}" data-status-id="{$info.order_status_id}" class="m-order-action">
                                    {$info.order_status_txt}
                                    {if condition="$info['order_status_id'] eq 0"}
                                    <!-- 待确认 -->
                                    <a data-order-status="1">确认订单</a>
                                    {elseif condition="$info['order_status_id'] eq 1"}
                                    <!-- 已确认 -->
                                    {elseif condition="$info['order_status_id'] eq 2"}
                                    <!-- 已取消 -->
                                    {elseif condition="$info['order_status_id'] eq 3"}
                                    <!-- 已关闭 -->
                                    {elseif condition="$info['order_status_id'] eq 4"}
                                    <!-- 待付款 -->
                                    <a data-pay-status="1">确认收款</a>
                                    {elseif condition="$info['order_status_id'] eq 5"}
                                    <!-- 待发货 -->
                                    <a data-shipping-status="1">确认发货</a>
                                    {elseif condition="$info['order_status_id'] eq 6"}
                                    <!-- 待收货 -->
                                    <a data-shipping-status="2">确认收货</a>
                                    {elseif condition="$info['order_status_id'] eq 7"}
                                    <!-- 申请退货 -->
                                    <a data-shipping-status="3">同意退货</a>
                                    {elseif condition="$info['order_status_id'] eq 8"}
                                    <!-- 退货中 -->
                                    <a data-shipping-status="4">确认退货</a>
                                    {elseif condition="$info['order_status_id'] eq 9"}
                                    <!-- 已退货 -->
                                    {elseif condition="$info['order_status_id'] eq 10"}
                                    <!-- 申请退款 -->
                                    <a data-pay-status="2">同意退款</a><a data-pay-status="3">取消退款</a>
                                    {elseif condition="$info['order_status_id'] eq 11"}
                                    <!-- 退款中 -->
                                    <a data-pay-status="4">确认退款</a>
                                    {elseif condition="$info['order_status_id'] eq 12"}
                                    <!-- 拒绝退款 -->
                                    {elseif condition="$info['order_status_id'] eq 13"}
                                    <!-- 已退款 -->
                                    {elseif condition="$info['order_status_id'] eq 14"}
                                    <!-- 已收货 -->
                                    {elseif condition="$info['order_status_id'] eq 15"}
                                    <!-- 已完成 -->
                                    {/if}
                                </td>
                                
                            </tr>
                            <tr>
                                <td width="15%"><label>兑换时间</label></td>
                                <td width="35%">{$info.pay_time_date}</td>
                                <td width="15%"><label>发货时间</label></td>
                                <td width="35%">{$info.send_time_date}</td>
                            </tr>
                            <tr>
                                <td width="15%"><label>签收时间</label></td>
                                <td width="35%">{$info.sign_time_date}</td>
                                <td width="15%"><label>订单完成时间</label></td>
                                <td width="35%">{$info.finish_time_date}</td>
                            </tr>
                        </tbody>
                        <thead>
                            <tr>
                                <th colspan="4">订单商品</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td colspan="4">
                                    <table class="m-table m-fields">
                                        <thead>
                                            <tr>
                                                <th width="70%">商品名称</th>
                                                <th width="10%">支付积分</th>
                                                <th width="10%">数量</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                         
                                            {foreach name="$info['goods_list']" item="v"}
                                            <tr>
                                                <td>{$v.goods_name}</td>
                                                <td>{$v.point}</td>
                                                <td>{$v.goods_nums}</td>
                                            </tr>
                                            {/foreach}
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>
    <style>
    #masklll{width:100%;height:100%;position:fixed;background:rgba(0,0,0,0.3);display:none}
	#masklll div{width:300px;height:200px;position:absolute;left:0;right:0;bottom:0;top:0;margin:auto;background:#fff}
    #masklll .title{text-align:center;line-height:50px;font-size:16px}
	#masklll input{width:200px;margin:20px auto;line-height:40px}
	#masklll ul{width:100%;position:absolute;bottom:0;left:0}
	#masklll ul li{width:50%;float:left;line-height:40px;text-align:center;background:#ddd}
    </style>
    <div id='masklll'>
    	<div>
    		<p class='title'>请输入快递单号</p>
    		<input type='text' id='wenxintishi' value='' style='display:block'>
    		<input type='hidden' id='shipping_status' value=''>
    		<input type='hidden' id='ids' value=''>
    		<input type='hidden' id='order_status' value=''>
    		<input type='hidden' id='pay_status' value=''>
    		<ul>
    			<li class='queding' style='background:#c00;color:#fff' onclick='queding()'>确定</li>
    			<li class='quxiao' onclick='quxiao()'>取消</li>
    		</ul>
    	</div>
    </div>
</div>
{/block}
{block name="extrajs"}
<script>
    $(function(){
        $('.m-order-action a').on('click', function(){
            var id              = $(this).parent().attr('data-id');
            var order_status    = $(this).attr('data-order-status');
            var pay_status      = $(this).attr('data-pay-status');
            var shipping_status = $(this).attr('data-shipping-status');
            var status = {
                id: id
            };
            if (typeof(order_status) !== "undefined") {
                status.order_status = order_status;
            }
            if (typeof(pay_status) !== "undefined") {
                status.pay_status = pay_status;
            }
            if (typeof(shipping_status) !== "undefined") {
                status.shipping_status = shipping_status;
            }
            if(shipping_status == 1){
            	$('#shipping_status').val(shipping_status)
            	$('#ids').val(id)
            	$('#masklll').show();
            	
            }else{
            	layer.confirm('您确定要执行此操作吗？', {
                    btn: ['确定', '取消']
                }, function(){
                    $.post('{:url("orderAction")}', status, function(ret){
                        if (ret.status == 0) {
                            dialog.success(ret.message, function(){
                                window.location.reload();
                            });
                        } else {
                            dialog.error(ret.message);
                        }
                    }, 'json');
                }, function(){
                    
                });
            }
            //询问框
            
        });
        
        
    })
    function queding(){
    	var statuse = {
                id: $('#ids').val(),
                value: $('#wenxintishi').val(),
                
        };
    	if (typeof($('#shipping_status').val()) != "undefined") {
        	statuse.shipping_status = $('#shipping_status').val();
        }
    	console.log(statuse)
    	$.post('{:url("orderAction")}', statuse, function(ret){
                        if (ret.status == 0) {
                            dialog.success(ret.message, function(){
                                window.location.reload();
                            });
                        } else {
                            dialog.error(ret.message);
                        }
                    }, 'json');
    	quxiao()
    }
	function quxiao(){
		$('#masklll').hide();
    }
</script>
{/block}